<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="../css/aui.2.0.css">
    <link rel="stylesheet" href="../css/reset.css">
    <link rel="stylesheet" href="../css/alert.css">
    <link rel="stylesheet" href="../css/common1.css">
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/my.css">
<style>
html, body{
background: #f2f2f2;
}

.rDialog-wrap-confirm .rDialog-cancel{
	
	display:none;
}
.rDialog-wrap-confirm .rDialog-close{
    
    display:none;
}
</style>
</head>
<body>

<div id="my-content">
    <script type="text/x-handlebars-template" id="my-template">
        <div class="my-box1" id="my-box1">
            <header>
                <div class="my-user-photo">
                    <img class="user-photo" src="{{userHeadImg}}" alt="">
                </div>
                <div class="member-info">
                    <div class="userNameInput1">
                        <i class="userName">{{userNickName}}</i>
                        <b class="xg1"></b>
                    </div>
                    <div class="userNameInput2">
                        <input class="userName1" type="text" value={{userNickName}}>
                        <div class="confirm-button">确定</div>
                    </div>

                    {{#valueCompare userPhone '===' ''}}
                    <div class="userPhone"><a id="bind-phone" href="bindingtel.html">绑定手机号</a></div>
                    {{/valueCompare}}
                    {{#valueCompare userPhone '!==' ''}}
                    <div class="userPhone"><a href="bindingtel.html">{{userPhone}}</a></div>
                    {{/valueCompare}}
                </div>
            </header>
            <div class="member-withdraw">
                <div>可提现余额 <span>{{money}}元</span></div>
               
            </div>
            <div class="member-order">
                <ul class="member-order-list">
					
					 <li class="li-bor0" style=" border-right: 5px solid #f2f2f2;">
                        <div class="one"></div>
                        <div>
                            <span class="ab e9-color">提现</span><br>
                            <!--<span>{{preProfit}}</span>-->
                      </div>
                    </li>
					 
                    <li class="li-bor">
                        <div class="three"></div>
                        <div>
                            <span class="ab e9-color">收入明细</span><br>
                            <!--<span>{{preProfit}}</span>-->
                        </div>
                    </li>
					 <li class="li-bor1" style="border-right: 5px solid #f2f2f2;">
                        <div class="threes"></div>
                        <div>
                            <span class="ab e9-color">预估收入</span><br>
                            <!--<span>{{preProfit}}</span>-->
                        </div>
                    </li>
                    <li class="li-center">
                        <div class="four"></div>
                        <div>
                            <span class="cd e9-color">入驻邀请</span><br>
                        </div>
                    </li>

                </ul>
            </div>

        </div>
        <!--列表-->
        <div class="member-info-entry">
            <ul class="member-info-list">
                <li>
                    <a href="myShop.html" class="display-box">
                        我的店铺
                    </a>
                </li>
				<!--<li>
                    <a href="achevement.html" class="display-box">
                  京东订单查询
                    </a>
                </li>-->
                <li>
                    <a href="teamadmin.html" class="display-box">
                        邀请记录
                    </a>
                </li>
                <!--
				 <li>
                    <a href="buyer_detail.html" class="display-box">
                        买家管理
                    </a>
                </li>
				<li>
                    <a href="javascript:;" class="display-box">
                        分享明细
                    </a>
                </li>-->
       
            </ul>
			<ul class="member-info-list">
				         <li>
                    <a href="aboutus.html" class="display-box">
                        关于我们
                </li>
                <!--<li class="bind-tel-box">
                    <a href="bindingtel.html" class="display-box">
                        <i>绑定手机号</i>
                        <span style="padding-left: 5rem;">{{userPhone}}</span>
                    </a>
                </li>-->
                <li style="border-bottom:0;">
                    <a href="set.html" class="display-box" id="shezhi" >
                        设置
                    </a>
                </li>
			</ul>
        </div>
    </script>
</div>

<footer class="aui-bar aui-bar-tab" id="footer" style="display:none;">
    <a href="index.html">
        <div class="aui-bar-tab-item" tapmode>
            <img class="footer-icon-img" src="../images/JD_click.png" alt="">
            <div class="aui-bar-tab-label">首页</div>
        </div>
    </a>
    <a href="extension.html">
        <div class="aui-bar-tab-item" tapmode>
            <i class="aui-iconfont aui-icon-calendar"></i>
            <div class="aui-bar-tab-label">分享中心</div>
        </div>
    </a>
    <a href="commodity.html">
        <div class="aui-bar-tab-item" tapmode>
            <i class="aui-iconfont aui-icon-cert"></i>
            <div class="aui-bar-tab-label">商品中心</div>
        </div>
    </a>
    <a href="javascript:;">
        <div class="aui-bar-tab-item my-aui-active" tapmode>
            <i class="aui-iconfont aui-icon-my"></i>
            <div class="aui-bar-tab-label">我</div>
        </div>
    </a>
</footer>
<script src="../js/jquery-3.0.0.min.js"></script>
<script src="../js/config.js"></script>
<script src="../js/function.js"></script>
<script src="../js/alert.js"></script>
<script src="../js/handlebars-v4.0.10.js"></script>
<script src="../js/common.js"></script>
<script>
    //获得slider插件对象
//    var gallery = mui('.mui-slider');
//    gallery.slider({
//        interval:5000//自动轮播周期，若为0则不自动播放，默认为0；
//    });
//    设置当前秒杀时间
//    $('.seckillTime ul li').click(function(){
//        $(this).parent().find('a').removeClass('seckillTime-active');
//        $(this).parent().find('p:nth-child(even)').text('即将开始');
//        $(this).find('a').addClass('seckillTime-active');
//        $(this).find('p').eq(1).text('已开枪');
//    })



    /**
     * 判断是iOS或是安卓，改变数据的获取方式
     *
     * */
	// alert(1);
    var ua = navigator.userAgent.toLowerCase();
    if (/iphone|ipad|ipod/.test(ua)) {
        //alert('iOS的弹窗');
        var data={
            postType:'getToken'
        };
        postSuccessToken(data);

    } else {
        //alert('android的弹窗。');
        postAndroidToken();
    }

    //调用ios获取token方法。
    function postSuccessToken(data) {
        window.webkit.messageHandlers.postSuccessToken.postMessage(data);
    }

    //调用Android获取token方法
    function postAndroidToken() {
        window.getToken();
    }

    function getToken(token) {
        localStorage.setItem('token',token);
       // alert('获取到的token为'+token);
      
        
    }
</script>
<script>
    
    var a = $('#my-template').html();
    var b = Handlebars.compile(a);

    //var token=localStorage.getItem('token');
   /*
	var href = window.location.href;
	var href_token = href.split("?")[1];
	if(href_token == undefined){
		dialog.tusiError('请重新登录');
        againLogin();
	}else{
		var ss = href_token.split("=")[1];
		localStorage.setItem('token',ss);
	}*/
	var href = window.location.href;
	if(href.indexOf('?')>0){
		var href_token = href.split("?")[1];
		
			var ss = href_token.split("=")[1];
			localStorage.setItem('token',ss);
			//console.log(ss);
			
	}
	
	//绑定手机号
	
    $.ajax({
        url: C.marketInterface.isHavePhone,
        type: 'post',
        dataType: 'json',
        data: {
            token: C.marketToken
        },
        success: function (data) {
           
            if(data.result == "success"){
            	
            	if(data.data == ""){
            		$(".rDialog-cancel").hide();
            		dialog.confirm({
                        title: "亲,您还没有绑定手机号哦！",
                        content: "",
                        
                        ok: function () {
                        	
                            location.href = "bindingtel.html";
                           
                        },
                        cancel: function () {

                        }
                    });
            	}
            }
        }
    });
	
    /***********/
    $.ajax({
        url: C.marketInterface.my,
        type: 'post',
        dataType: 'json',
        data: {
            token: C.marketToken
        },
        success: function (data) {
            if (data.result == 'success') {
                var data = data.data;
                $('#my-content').html(b(data));

                //修改昵称
                $('.userNameInput2').hide();
                $('.userNameInput1').click(function () {
                    $('.userNameInput1').css('display', 'none');
                    $('.userNameInput2').show();

                    $('.confirm-button').unbind().bind('click',insertName);

                });

                $('.li-bor').click(function () {
                    location.href = 'generalize_detail.html';
                });
                $(".li-bor1").click(function(){
                	 location.href = 'estimate_detail.html';
                })
                $('.li-center').bind('click',goEenterInvite);
                /*$('.li-center').bind('click',function () {
                    location.href = 'invite_enter.html';
                });*/
				$(".li-bor0").click(function(){
					location.href = 'tixian.html';
				})
				// $("#shezhi").bind('click',shezhibut);
				 $(document).on('click', '#shezhi', function () {
					//alert('11');
					shezhibut()
				}); 
            } else if (data.result == 'login') {
            	dialog.tusiError('登录已过期，请重新登录');
                againLogin();
            } else {
            	dialog.tusiError(data.errorMsg);
            }
        }
    });

    function goEenterInvite() {
        var ua = navigator.userAgent.toLowerCase();
        var inviteData = {
            postType:'inviteEnter'
        };
        if (/iphone|ipad|ipod/.test(ua)) {
            iosJumpInvite(inviteData)
        } else {
            androidJumpInvite(JSON.stringify(inviteData));
        }
    }
	function shezhibut(){
	    event.stopPropagation();
		var ua = navigator.userAgent.toLowerCase();
        var inviteData = {
            postType:'shezhiIndo'
        };
        if (/iphone|ipad|ipod/.test(ua)) {
        	//$("#shezhi").attr("href","javascript:;");
        	shezhiIndo(inviteData);
        }
	}
	function shehziinfor(data){
		window.webkit.messageHandlers.shezhiIndo.postMessage(param);
	}
    //修改昵称
    function insertName(event) {
        event.stopPropagation();
        var name = $.trim($('.userName1').val());
        if (name.length >= 16 ||name.length == 0){
        	dialog.tusiError('名字过长或过短，请重新输入');
        }else {
            var loading = dialog.loading();
            $.ajax({
                url: C.marketInterface.name,
                type: 'post',
                dataType: 'json',
                data: {
                    token: C.marketToken,
                    name: name
                },
                complete:function () {
                    loading.close()
                },
                success: function (data) {
                    console.log(data);
                    $('.userNameInput2').hide();
                    $('.userNameInput1').show();
                    $('.userName').html(name);
                }
            })
        }

    }

    function androidJumpInvite(param) {
        window.huifa.inviteEnter(param)
    }
    function iosJumpInvite(param) {
        window.webkit.messageHandlers.inviteEnter.postMessage(param);
    }

  
   

</script>
</body>
</html>